import { fileURLToPath } from 'node:url';
import { defineConfig } from 'rollup';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';
// import polyfillNode from 'rollup-plugin-polyfill-node'

export default defineConfig({
  input: 'src/index.js',
  output: {
    file: fileURLToPath(new URL('dist/jdcall-jssdk.js', import.meta.url)),
    name: 'JdWebCall',
    format: 'iife',
  },
  plugins: [
    json(),
    nodeResolve(),
    commonjs(),
    builtins(),
    globals(),
    // polyfillNode()
  ],
});
